//
//  VisitorTableViewController.swift
//  MyBlog
//
//  Created by User on 16/4/7.
//  Copyright © 2016年 personal. All rights reserved.
//

import UIKit

class VisitorTableViewController: UITableViewController {
 private var userLogon = false
    
    var visitorView:VisitorView?
    
    override func viewDidLoad() {
        super.viewDidLoad()

        userLogon ? super.loadView(): setUpVisitorView()
        
    }
    
    override func viewDidAppear(animated: Bool) {
        super.viewDidAppear(animated)
        print(visitorView)
    }
    
    private func setUpVisitorView(){
    
    visitorView = VisitorView()
        
        view = visitorView
        //为什么没有这句话View是黑的
//        view.backgroundColor = UIColor.whiteColor()
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: .Plain, target: self, action:"visitorViewDidRegister")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: .Plain, target: self, action: "visistorViewDidLogin")
        visitorView?.registerButton.addTarget(self, action: "visitorViewDidRegister", forControlEvents: .TouchUpInside)
    visitorView?.loginButton.addTarget(self, action: "visistorViewDidLogin", forControlEvents: .TouchUpInside)
    }
  
}
extension VisitorTableViewController{
 @objc private func visitorViewDidRegister(){
    
    print("注册")
    }
  @objc private func visistorViewDidLogin(){
    print("登录")
    
    }

}